
#include "Missile.h"

int CMissile::Start(int baseX, int baseY, RECT clipRect)
{
	// this function starts the missle, if it is currently off
	// computer position of missile
	m_missile_x = baseX;
	m_missile_y = baseY;

	memcpy(&m_clipRect, &clipRect, sizeof(RECT));

	// return success

	return 0;

} // end Start_Missile

int CMissile::Draw(CDDraw* pDDraw)
{
	if (pDDraw == NULL)
		return -1;

	// this function draws the missile 
	pDDraw->Lock_Back_Surface();
	m_line.Init(pDDraw->GetBackBuffer(), pDDraw->GetBackLpitch(), m_clipRect);

	// draw the missile in green
	m_line.Draw_Line(m_missile_x, m_missile_y, 
		m_missile_x, m_missile_y+6,
		250);

	pDDraw->Unlock_Back_Surface();

	// return success
	return 0;


} // end Draw_Missle

int CMissile::Move(int offsetX, int offsetY)
{
	// this function moves the missle 

	m_missile_y += offsetY;
	// move the missile upward
	if (m_missile_y < 0)
	{
		m_missile_y = 0;
		return 0;
	} // end if
	else if (m_missile_y > m_clipRect.bottom)
	{
		m_missile_y = m_clipRect.bottom;
		return 0;
	}

	// lock secondary buffer
	//DDraw_Lock_Back_Surface();

	// add missile collision here


	// unlock surface
	//DDraw_Unlock_Back_Surface();

	// return success
	return 0;


} // end Move_Missle